package com.ht.temp.controller;


import com.ht.temp.entity.Home;
import com.ht.temp.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mayke_zhou
 * @since 2018-12-25
 */
@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private IHomeService iHomeService;

    @RequestMapping("/getAllHome")
    public List<Home> selectByHome(Home home){
      return   iHomeService.selectByHome(home);
    }

    @RequestMapping("/getAllHomes")//查询所有房间信息不带设备
    public List<Home> getAllHomes(){
        return   iHomeService. getAllHome();
    }

    @RequestMapping(value = "/addHomes",method = RequestMethod.POST)//插入房间信息
    public Integer addHomes(Home home){
        return   iHomeService.insertSelective(home);
    }


    @RequestMapping(value ="/editHomes",method = RequestMethod.POST)//修改房间信息
    public Integer editHomes(Home home){
        return   iHomeService.updateByPrimaryKeySelective(home);
    }

    @RequestMapping(value ="/removeHomes",method = RequestMethod.POST)//删除房间信息
    public Integer removeHomes(Integer homeId){
        return   iHomeService.deleteByPrimaryKey(homeId);
    }
}
